package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.service.WrongService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @auther wangchenghao
 * @date 2020/8/15
 **/
@Controller
@ResponseBody
@RequestMapping("wrong")
public class WrongController {
    @Autowired
    WrongService wrongService;
    @ApiOperation(value = "获得用户错题")
    @RequestMapping(value = "/getWrongList", method = {RequestMethod.GET})
    @ResponseBody
    public BaseModel addUserPoints(@ApiParam("用户id") @RequestParam(value = "user_id", required = true) int user_id) {
        BaseModel baseModel = new BaseModel();
        try {
            wrongService.selectUserWrong(user_id,baseModel);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return baseModel;
    }
    @ApiOperation(value = "增加用户错题")
    @RequestMapping(value = "/addWrongPoem", method = {RequestMethod.POST})
    @ResponseBody
    public BaseModel addWrongPoem(@ApiParam("用户id") @RequestParam(value = "user_id", required = true) int user_id,
                                  @ApiParam("资源id") @RequestParam(value = "source_id", required = true) int source_id) {
        BaseModel baseModel = new BaseModel();
        try {
            wrongService.addWrongPoem(user_id,source_id,baseModel);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return baseModel;
    }
}
